<?php /* Smarty version 2.6.13, created on 2008-10-28 17:02:20
         compiled from menu_list.tpl */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('modifier', 'escape', 'menu_list.tpl', 65, false),array('function', 'html_options', 'menu_list.tpl', 70, false),)), $this); ?>
<table>
  <tr>
    <td id="leftpanel" valign="top">
        <div id="leftpaneldiv">
            <a href="javascript:void(0);" id="hidePanel"><img id="collapse" src="<?php echo $this->_tpl_vars['fvConfig']->get('dir_web_root'); ?>
img/collapse.gif" width="15" height="15"></a>
            <div class="header" id="leftPanelHeader">Список страниц</div>
            <div id="leftpaneldata">
                <ul id="sortables">
                <?php unset($this->_sections['menuItem']);
$this->_sections['menuItem']['name'] = 'menuItem';
$this->_sections['menuItem']['loop'] = is_array($_loop=$this->_tpl_vars['Menus']) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
$this->_sections['menuItem']['show'] = true;
$this->_sections['menuItem']['max'] = $this->_sections['menuItem']['loop'];
$this->_sections['menuItem']['step'] = 1;
$this->_sections['menuItem']['start'] = $this->_sections['menuItem']['step'] > 0 ? 0 : $this->_sections['menuItem']['loop']-1;
if ($this->_sections['menuItem']['show']) {
    $this->_sections['menuItem']['total'] = $this->_sections['menuItem']['loop'];
    if ($this->_sections['menuItem']['total'] == 0)
        $this->_sections['menuItem']['show'] = false;
} else
    $this->_sections['menuItem']['total'] = 0;
if ($this->_sections['menuItem']['show']):

            for ($this->_sections['menuItem']['index'] = $this->_sections['menuItem']['start'], $this->_sections['menuItem']['iteration'] = 1;
                 $this->_sections['menuItem']['iteration'] <= $this->_sections['menuItem']['total'];
                 $this->_sections['menuItem']['index'] += $this->_sections['menuItem']['step'], $this->_sections['menuItem']['iteration']++):
$this->_sections['menuItem']['rownum'] = $this->_sections['menuItem']['iteration'];
$this->_sections['menuItem']['index_prev'] = $this->_sections['menuItem']['index'] - $this->_sections['menuItem']['step'];
$this->_sections['menuItem']['index_next'] = $this->_sections['menuItem']['index'] + $this->_sections['menuItem']['step'];
$this->_sections['menuItem']['first']      = ($this->_sections['menuItem']['iteration'] == 1);
$this->_sections['menuItem']['last']       = ($this->_sections['menuItem']['iteration'] == $this->_sections['menuItem']['total']);
?>
                    <?php if ($this->_tpl_vars['Menus'][$this->_sections['menuItem']['index']]['parent_id'] && ( $this->_sections['menuItem']['index_prev'] != -1 ) && ( $this->_tpl_vars['Menus'][$this->_sections['menuItem']['index_prev']]['parent_id'] == 0 )): ?>
                        <ul><li id="sortables_<?php echo $this->_tpl_vars['Menus'][$this->_sections['menuItem']['index']]->getPk(); ?>
">
                    <?php else: ?>
                        <li id="sortables_<?php echo $this->_tpl_vars['Menus'][$this->_sections['menuItem']['index']]->getPk(); ?>
">
                    <?php endif; ?>
                    <div style="float: right">
        <A 
           href="<?php echo $this->_tpl_vars['fvConfig']->get('dir_web_root'); ?>
menus/?id=<?php echo $this->_tpl_vars['Menus'][$this->_sections['menuItem']['index']]->getPk(); ?>
" 
        onclick="go('<?php echo $this->_tpl_vars['fvConfig']->get('dir_web_root'); ?>
menus/?id=<?php echo $this->_tpl_vars['Menus'][$this->_sections['menuItem']['index']]->getPk(); ?>
'); return false;"
        ><img src="<?php echo $this->_tpl_vars['fvConfig']->get('dir_web_root'); ?>
img/edit_icon.png" title="редактировать" width="16" height="16"></a><a
           href="javascript: void(0);" 
        onclick="if (confirm('Вы действительно желаете удалить пункт меню. Все дочерние меню перенесутся в корень.')) go('<?php echo $this->_tpl_vars['fvConfig']->get('dir_web_root'); ?>
menus/delete/?id=<?php echo $this->_tpl_vars['Menus'][$this->_sections['menuItem']['index']]->getPk(); ?>
'); return false;"
        ><img src="<?php echo $this->_tpl_vars['fvConfig']->get('dir_web_root'); ?>
img/delete_icon.png" title="удалить" width="16" height="16"></a>
                    </div><div class="<?php if ($this->_tpl_vars['Menus'][$this->_sections['menuItem']['index']]->getPk() == $_REQUEST['id']): ?>selected<?php endif; ?>"><?php echo $this->_tpl_vars['Menus'][$this->_sections['menuItem']['index']]['name']; ?>
</div><div style="clear: both;"></div>
                    
                    <?php if ($this->_tpl_vars['Menus'][$this->_sections['menuItem']['index']]['parent_id'] == 0 && $this->_tpl_vars['Menus'][$this->_sections['menuItem']['index_next']]['parent_id'] != 0): ?>
                    <?php else: ?>
                        </li>
                    <?php endif; ?>
                    <?php if ($this->_tpl_vars['Menus'][$this->_sections['menuItem']['index']]['parent_id'] && ( ( ! $this->_sections['menuItem']['last'] && ( $this->_tpl_vars['Menus'][$this->_sections['menuItem']['index_next']]['parent_id'] == 0 ) ) || $this->_sections['menuItem']['last'] )): ?>
                        </li></ul></li>
                    <?php endif; ?>
                <?php endfor; endif; ?>
                </ul>
                <?php echo '
                <script>
                    Sortable.create("sortables", {
                        tree: true,
                        onChange: function () {
                            //alert(1);
                        },
                        onUpdate: function () {
                            new Ajax.Request("';  echo $this->_tpl_vars['fvConfig']->get('dir_web_root'); ?>
menus/reorder/<?php echo '", {
                                parameters: Sortable.serialize("sortables")
                            });
                        }
                    });
                </script>
                '; ?>

                <div class="operation">
                    <a href="<?php echo $this->_tpl_vars['fvConfig']->get('dir_web_root'); ?>
menus/" onclick="go('<?php echo $this->_tpl_vars['fvConfig']->get('dir_web_root'); ?>
menus/'); return false;" class="add">добавить</a>
                </div>                
            </div>
        </div>
    </td>
    <td class="spacer">&nbsp;</td>
    <td id="datapanel">

<div class="form">
    <H1><?php if ($this->_tpl_vars['Menu']->isNew()): ?>Добавление пункта меню<?php else: ?>Редактирование пункта меню '<?php echo $this->_tpl_vars['Menu']->name; ?>
'<?php endif; ?></H1>
    <form method="post" action="/backend/menus/save/">
    <fieldset>
        <legend>Общая информация</legend>
        <table class="form">
        <tr><td style="width: 1px;">
        <label for="name">Название</label></td><td> <input type="text" id="name" name="mn[name]" value="<?php echo ((is_array($_tmp=$this->_tpl_vars['Menu']->name)) ? $this->_run_mod_handler('escape', true, $_tmp) : smarty_modifier_escape($_tmp)); ?>
"/>
        </td></tr> <tr><td>
        <label for="url">URL на который ссылается пункт меню</label></td><td><input type="text" id="url" name="mn[url]" value="<?php echo ((is_array($_tmp=$this->_tpl_vars['Menu']->url)) ? $this->_run_mod_handler('escape', true, $_tmp) : smarty_modifier_escape($_tmp)); ?>
" /> <br />
        </td></tr><tr><td>
        <label for="page_parent_id">Родительский пункт меню</label></td><td>
        <?php echo smarty_function_html_options(array('name' => "mn[parent_id]",'id' => 'parent_id','options' => $this->_tpl_vars['MenuManager']->htmlSelect('name',"","parent_id = 0 AND id <> ?",'','',$this->_tpl_vars['Menu']->getPk()),'selected' => $this->_tpl_vars['Menu']->parent_id), $this);?>

        </td></tr>
        </table>
    </fieldset> 
    
    <fieldset>
        <legend>Параметры</legend>
        <table class="form">
        <tr><td style="width: 1px;">
        <label for="type">тип пункта</label></td><td> 
            <select name="mn[type]" id="type">
                <option value="1" <?php if ($this->_tpl_vars['Menu']['type'] == 1): ?>selected="selected"<?php endif; ?>>основной пункт меню</option>
                <option value="2" <?php if ($this->_tpl_vars['Menu']['type'] == 2): ?>selected="selected"<?php endif; ?>>дополнительный пункт меню</option>
            </select>
        </td></tr><tr><td colspan="2">
            <input type="checkbox" name="mn[is_show]" value="1" id="is_show" <?php if ($this->_tpl_vars['Menu']['is_show'] || $this->_tpl_vars['Menu']->isNew()): ?>checked="true"<?php endif; ?>><label for="is_show" class="checkbox">отображать пункт меню</label> <br />        </td></tr>
        </table>
    </fieldset> 

    <div class="buttonpanel">
        <input type="submit" name="save" value="Сохранить" class="button">
    </div>
    <input type="hidden" name="id" id="id" value="<?php echo $this->_tpl_vars['Menu']->getPk(); ?>
" />
    <input type="hidden" name="mn[image]" value="<?php echo $this->_tpl_vars['Menu']['image']; ?>
" id="image">
    
    </form>
    <form method="post" enctype="multipart/form-data" target="upload_iframe" action="<?php echo $this->_tpl_vars['fvConfig']->get('dir_web_root'); ?>
menus/uploadimage/">
    <fieldset>
        <legend>Изображение</legend>
        <table class="form">
        <tr><td style="width: 1px;">
        <label for="type">Изображение к пункту меню</label></td><td>
            <input type="file" name="image" style="width:500px">
        </td><td>
            <input type="submit" name="save" value="загрузить" class="button">
        </td></tr>
        </table>
        <iframe id="upload_iframe" name="upload_iframe" src="javascript:void(0);" style="display: none;"></iframe>
        
        <div id="preview_div" style="text-align: center; border: 0px solid red; <?php if (! $this->_tpl_vars['Menu']->hasFile('image','small')): ?>display: none;<?php endif; ?>">
            <?php if ($this->_tpl_vars['Menu']->hasFile('image','small')): ?>
                <img id="preview" <?php echo $this->_tpl_vars['Menu']->getImageSize('image','small'); ?>
 style="border: 0px solid none;" src="<?php echo $this->_tpl_vars['Menu']->getImageDir(true);  echo $this->_tpl_vars['Menu']->getImageName('image','small'); ?>
" /><br />
                <a href="javascript: void(0);" id="deleteImage" style="font-size: 12px; color: blue; text-decoration: underline;">удалить</a>
            <?php else: ?>
                <img id="preview" width="<?php echo $this->_tpl_vars['fvConfig']->get('images.small.width'); ?>
" style="border: 0px none;" src="" /><br />
                <a href="javascript: void(0);" id="deleteImage" style="font-size: 12px; color: blue; text-decoration: underline;">удалить</a>
            <?php endif; ?> 
        </div>
    </fieldset> 
    </form>

</div>

    </td>
  </tr>
</table>

<?php echo '
<script>
    function moveLeftPanel (e) {
        if ($(\'leftpanel\').getDimensions().width > 100) {
            $(\'leftpanel\').morph(\'width: 20px;\');
            $(\'leftPanelHeader\').update("");
            $(\'leftpaneldata\').hide();
            $(\'collapse\').src = \'';  echo $this->_tpl_vars['fvConfig']->get('dir_web_root'); ?>
img/expand.gif<?php echo '\';
        } else {
            $(\'leftpanel\').morph(\'width: 300px;\');
            $(\'collapse\').src = \'';  echo $this->_tpl_vars['fvConfig']->get('dir_web_root'); ?>
img/collapse.gif<?php echo '\';
            setTimeout("$(\'leftPanelHeader\').update(\'Список страниц\')", 1000);
            setTimeout("$(\'leftpaneldata\').show()", 1000);
        }
    }
    
    function deleteImage() {
        if (confirm(\'Вы действительно хотите удалить изображение?\')) {
            window.blockScreen();
	        new Ajax.Request(\'';  echo $this->_tpl_vars['fvConfig']->get('dir_web_root'); ?>
menus/deleteImage/<?php echo '\',{
	            parameters: {id: $F(\'id\'), image: $F(\'image\')},
	            onSuccess: function (transport, json) {
	                window.completeRequest(transport);
	                if (json && json.image) {
	                    
	                    $(\'image\').value = json.image.split(\'/\').slice(-1).join(\'\');
	                    if ($(\'preview\')) {
	                        $(\'preview\').src = json.image;
	                        $(\'preview\').width = json.width;
	                        $(\'preview\').height = json.height;
	                    }
	                } else {
	                    $(\'preview_div\').hide();
	                    $(\'image\').value = \'\';
	                }
	            }
	        });
        }
    }
    
    $(\'deleteImage\').observe(\'click\', deleteImage);
    
    Object.extend(window, {
        updateImage: function (imageName, width, height) {          
            if ($(\'preview\')) {
                $(\'preview\').src = \'';  echo $this->_tpl_vars['fvConfig']->get('path.upload.web_tmp_dir');  echo '\' + imageName;
                $(\'preview\').width = width;
                $(\'preview\').height = height;
            }
            $(\'image\').value = imageName;
            if (imageName != \'\')
                $(\'preview_div\').show();
            else 
                $(\'preview_div\').hide();
        }
    });

    
    $(\'hidePanel\').observe(\'click\', moveLeftPanel);
</script>
'; ?>